<script setup lang="ts">
import {useRouter} from "vue-router";
import {ref} from "vue";
import myAxios from "../plugins/myAxios";

const router = useRouter();
const userAccount = ref('');
const userPassword = ref('');
const checkPassword = ref('');
const onSubmit = async () => {
  const res = await myAxios.post("/register", {
        userAccount: userAccount.value,
        userPassword: userPassword.value,
    checkPassword:checkPassword.value,
      }
  )
  console.log("用户注册");
  // @ts-ignore
  if (res?.code === 200 && res.data) {
    router.replace("/my/login");
  } else {
  }
};
</script>

<template>
  <van-form @submit="onSubmit" STYLE="margin-top:50px">
    <van-cell-group inset>
      <van-field
          v-model="userAccount"
          name="userAccount"
          label="账号"
          placeholder="账号"
          :rules="[{ required: true, message: '请填写账号' }]"
      />
      <van-field
          v-model="userPassword"
          type="password"
          name="密码"
          label="密码"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]"
      />
      <van-field
          v-model="checkPassword"
          type="password"
          name="密码"
          label="密码"
          placeholder="再次输入密码"
          :rules="[{ required: true, message: '请再次填写密码' }]"
      />
    </van-cell-group>
    <div style="margin: 16px;">
      <van-button round block type="primary" native-type="submit">
        快速注册
      </van-button>
    </div>
  </van-form>

</template>

<style scoped>

</style>